package com.itheima.imclient100.utils;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by fullcircle on 2017/7/3.
 */

public class SPUtils {
    private static SharedPreferences sp = null;

    private  static void getsp(Context context){
        if(sp == null)
        sp = context.getSharedPreferences("config",Context.MODE_PRIVATE);
    }

    public static String getUsername(Context context){
        getsp(context);
        return sp.getString("username","");
    }

    public static String getPassword(Context context){
        getsp(context);
        return sp.getString("password","");
    }

    public static void saveUsername(Context context,String username){
        getsp(context);
        sp.edit().putString("username",username).commit();
    }

    public static void savePassword(Context context,String password){
        getsp(context);
        sp.edit().putString("password",password).commit();
    }
}
